package com.leetcode.dongtaiguihua;

/**
 * leetcode 53 最大子序和
 */
public class Solution53 {
    public int maxSubArray(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }

        int max = nums[0];
        int[] assist = new int[nums.length];
        assist[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            assist[i] = Math.max(assist[i-1] + nums[i], nums[i]);
            max = Math.max(max, assist[i]);
        }
        return max;
    }
}
